'''

Case Type： 人为因素
Case Name： 停止、启动数据库
Create At:  2020/10/13
@zou_jialiang0505328126
Descption: 1、停止数据库gs_om -t stop
2、启动数据库gs_om -t start
3、查看数据库的状态 gs_om -t status --detail

history：
created： 2020/10/13  created by @wan005
'''
import os
import unittest
from yat.test import Node
import time
from yat.test import macro
import sys
import datetime

sys.path.append(sys.path[0] + "/../")
from testcase.utils.Logger import Logger
from testcase.utils.Constant import Constant
from testcase.utils.Common import Common
from testcase.utils.CommonSH import *
from testcase.utils.ComThread import ComThread

logger = Logger()
common = Common('PrimaryRoot')
commonshpri = CommonSH('PrimaryDbUser')

class ModifyConnection(unittest.TestCase):
    dbPrimaryUserNode = Node(node='PrimaryDbUser')
    dbPrimaryRootNode = Node(node='PrimaryRoot')    
    DB_INSTANCE_PATH = macro.DB_INSTANCE_PATH
    DB_ENV_PATH = macro.DB_ENV_PATH
    Constant = Constant()

    nodes_tuple = ('PrimaryDbUser', 'Standby1DbUser', 'Standby2DbUser')
    @RestartDbCluster(*nodes_tuple)
    def setUp(self):
        logger.info("-----------this is setup-----------")
        logger.info("-----------reliability_humanfactor014 start-----------")

    def test_modify_pidfile(self):
        logger.info("-------------stop opengauss---------------------")
        result = commonshpri.stopDbInstance()
        self.assertTrue(result)

        logger.info("-------------start opengauss---------------------")
        result = commonshpri.startDbCluster()
        self.assertTrue(result)

        logger.info("-------------check opengauss status---------------------")
        result = commonshpri.getDbClusterStatus('status')
        self.assertTrue(result)

    def tearDown(self):
        logger.info('----------------this is tearDown-----------------------')
       